package cn.zzf.algs.note.base.util;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @author GaoFeng2017
 * @date 2020/6/19 10:00
 */
public class MathUtil {

    /** 求对数 */
    public static double log(int n, int baseNumber) {
        return Math.log(n) / Math.log(baseNumber);
    }

    public static float ratio(int firstNumber, int secondNumber) {
        return new BigDecimal(firstNumber).multiply(new BigDecimal(100))
                .divide(new BigDecimal(secondNumber), 2, RoundingMode.HALF_EVEN).floatValue();
    }

}
